package org.example.controller;


import org.example.form.SearchForm;
import org.example.service.MoveoutService;
import org.example.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2024-10-31
 */
@RestController
@RequestMapping("/moveout")
public class MoveoutController {
    @Autowired
    private MoveoutService moveoutService;

    @GetMapping("/list/{page}/{size}")
    public ResultVO list(@PathVariable Integer page, @PathVariable  Integer size) {
        return ResultVO.success(this.moveoutService.list(page, size));
    }
    @GetMapping("/search")
    public ResultVO search(SearchForm searchForm) {
        return ResultVO.success(this.moveoutService.search(searchForm));
    }
    @PutMapping("/moveout/{id}/{reason}")
    public ResultVO moveout(@PathVariable Integer id, @PathVariable String reason) {
        boolean moveout = this.moveoutService.moveout(id, reason);
        if (moveout) {
            return ResultVO.success(null);
        } else {
            return ResultVO.error("移出失败");
        }
    }
    @GetMapping("/moveoutList/{page}/{size}")
    public ResultVO moveoutList(@PathVariable Integer page, @PathVariable  Integer size) {
        return ResultVO.success(this.moveoutService.moveoutList(page, size));
    }
    @GetMapping("/moveoutSearch")
    public ResultVO moveoutSearch(SearchForm searchForm) {
        return ResultVO.success(this.moveoutService.moveoutSearch(searchForm));
    }
}

